﻿using System;
using System.Xml.Serialization;
using DC2010.Objects.Base;

namespace DC2010.Objects.Data
{
    [Serializable]
    public class EffectInfo : BaseInfo
    {
        /// <summary>
        /// What method will be used to execute this info.
        /// </summary>
        [XmlAttribute]
        public string Method { get; set; }

        //http://dmweb.free.fr/?q=node/690
        [XmlAttribute]
        public int HP_Consume { get; set; }             // this will be subeffect

        [XmlAttribute]
        public int MP_Consume { get; set; }             // this will be subeffect

        [XmlAttribute]
        public int SP_Consume { get; set; }             // this will be subeffect
        
        [XmlAttribute]
        public string Consumed_Item { get; set; }       // this will be subeffect
        
        [XmlAttribute]
        public int Consumed_Item_Count { get; set; }    // this will be subeffect

        [XmlAttribute]
        public int ChargesMax { get; set; }             // how many times u can use this effect
        
        [XmlAttribute]
        public int ChargesCurrent { get; set; }         // how many times u used this effect

        [XmlAttribute]
        public bool IsBuff { get; set; }

        [XmlAttribute]
        public double Probability { get; set; }

        /// <summary>
        /// How many seconds effect will not be usable. Re-use time.
        /// </summary>
        [XmlAttribute]
        public int DisableTime { get; set; }


        public EffectData CreateData()
        {
            EffectData ed = new EffectData();

            ed.InfoId = Id;
            ed.Id = ed.InfoId + "_" + Guid.NewGuid().ToString();
            //TODO: fill with other properties
            //TODO: parameters!
            Root.log.InfoFormat("Core, Created new object with id: {0} based on object {1}", ed.Id, ed.InfoId);
            Root.I.EffectSystem.AddData(ed);


            return ed;
        }
    }
}
